package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.LeaderReplyRepository;
import org.example.petitionplatformsystem.dao.model.LeaderReply;
import org.example.petitionplatformsystem.service.LeaderReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaderReplyServiceImpl implements LeaderReplyService {
    @Autowired
    private LeaderReplyRepository leaderReplyRepository;
    @Override
    public LeaderReply getLeaderReplyById(Long id) {
        return leaderReplyRepository.findById(id).orElse(null);
    }

    @Override
    public LeaderReply addLeaderReply(LeaderReply leaderReply) {
        return leaderReplyRepository.save(leaderReply);
    }

    @Override
    public LeaderReply updateLeaderReply(LeaderReply leaderReply) {
        return leaderReplyRepository.save(leaderReply);
    }

    @Override
    public void deleteLeaderReply(Long id) {
       leaderReplyRepository.deleteById(id);
    }

    @Override
    public LeaderReply getLeaderReplyByMailBoxId(Long id) {
        return leaderReplyRepository.findByMailboxId(id);
    }

    @Override
    public List<LeaderReply> getLeaderReplyByUserId(Long userid) {
        return leaderReplyRepository.findByUserId(userid);
    }

}
